﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FbKPI.Model;
using FbKPI.Facade;

namespace FBKPI.Pages
{
    public partial class KPICurrentAdmin : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //if (!IsPostBack)
           // {
                txt_rgmtype.Text = string.Empty;
                txt_rgm.Text = string.Empty;
                txt_location.Text = string.Empty;
                txt_subbranch.Text = string.Empty;
                txt_section.Text = string.Empty;
                txt_department.Text = string.Empty;


                if (txt_rgmtypeid.Value.Trim().Length > 0)
                {
                    RGMType objRgmType = new RGMTypeFacade().GetRGMTypeByID(Convert.ToInt32(txt_rgmtypeid.Value.Trim()));
                    txt_rgmtype.Text = objRgmType == null ? string.Empty : objRgmType.Description;
                }

                if (txt_rgmid.Value.Trim().Length > 0)
                {
                    RGM objRgm = new RGMFacade().GetRGMByID(Convert.ToInt32(txt_rgmid.Value.Trim()));
                    txt_rgm.Text = objRgm == null ? string.Empty : objRgm.Description;
                }

                if (txt_locationid.Value.Trim().Length > 0)
                {
                    Location objLocation = new LocationFacade().GetLocationByID(Convert.ToInt32(txt_locationid.Value.Trim()));
                    txt_location.Text = objLocation == null ? string.Empty : objLocation.Description;
                }

                if (txt_subbranchid.Value.Trim().Length > 0)
                {
                    SubBranch objSubBranch = new SubBranchFacade().GetSubBranchByID(Convert.ToInt32(txt_subbranchid.Value.Trim()));
                    txt_subbranch.Text = objSubBranch == null ? string.Empty : objSubBranch.Description;
                }

                if (txt_sectionid.Value.Trim().Length > 0)
                {
                    Section objSection = new SectionFacade().GetSectionByID(Convert.ToInt32(txt_sectionid.Value.Trim()));
                    txt_section.Text = objSection == null ? string.Empty : objSection.Description;
                }

                if (txt_departmentid.Value.Trim().Length > 0)
                {
                    Department objDep = new  DepartmentFacade().GetDepartmentByID(Convert.ToInt32(txt_departmentid.Value.Trim()));
                    txt_department.Text = objDep==null?string.Empty : objDep.Description;
                }
           // }
        }
    }
}